ad6410efaf1dd716dc0283826fb885b27f72ae22,portal-impl/src/com/liferay/portlet/messageboards/service/permission/MBCategoryPermission.java,MBCategoryPermission,contains,#PermissionChecker#MBCategory#String#,97

Before Change



		long categoryId = category.getCategoryId();

		if (actionId.equals(ActionKeys.VIEW)) {
			while (categoryId !=
					MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

				try {
					category = MBCategoryLocalServiceUtil.getCategory(
						categoryId);

					categoryId = category.getParentCategoryId();

					if (!permissionChecker.hasOwnerPermission(
							category.getCompanyId(), MBCategory.class.getName(),
							category.getCategoryId(), category.getUserId(),
							actionId) &&
						!permissionChecker.hasPermission(
							category.getGroupId(), MBCategory.class.getName(),
							category.getCategoryId(), actionId)) {

						return false;
					}

					if (!PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
						break;
					}
				}
				catch (NoSuchCategoryException nsce) {
					if (!category.isInTrash()) {
						throw nsce;
					}
				}
			}

			return true;
		}
		else {
			while (categoryId !=
					MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

				category = MBCategoryLocalServiceUtil.getCategory(categoryId);

				categoryId = category.getParentCategoryId();

				if (permissionChecker.hasOwnerPermission(
						category.getCompanyId(), MBCategory.class.getName(),
						category.getCategoryId(), category.getUserId(),
						actionId)) {

					return true;
				}

				if (permissionChecker.hasPermission(
						category.getGroupId(), MBCategory.class.getName(),
						category.getCategoryId(), actionId)) {

					return true;
				}

				if (actionId.equals(ActionKeys.VIEW)) {
					break;
				}
			}

			return false;
		}
	}

After Change


		long categoryId = category.getCategoryId();

		if (PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {
			MBCategory originalCategory = category;

			try {
				while (categoryId !=
						MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

					category = MBCategoryLocalServiceUtil.getCategory(
						categoryId);

					if (!permissionChecker.hasOwnerPermission(
							category.getCompanyId(), MBCategory.class.getName(),
							categoryId, category.getUserId(),
							ActionKeys.VIEW) &&
						!permissionChecker.hasPermission(
							category.getGroupId(), MBCategory.class.getName(),
							categoryId, ActionKeys.VIEW)) {

						return false;
					}

					categoryId = category.getParentCategoryId();
				}
			}
			catch (NoSuchCategoryException nsce) {
				if (!category.isInTrash()) {
					throw nsce;
				}
			}

			if (Validator.equals(actionId, ActionKeys.VIEW)) {
				return true;
			}

			categoryId = originalCategory.getCategoryId();
		}

		if (!PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE ||
			!Validator.equals(actionId, ActionKeys.VIEW)) {

			try {
				while (categoryId !=
						MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

					category = MBCategoryLocalServiceUtil.getCategory(
							categoryId);

					if (permissionChecker.hasOwnerPermission(
							category.getCompanyId(), MBCategory.class.getName(),
							categoryId, category.getUserId(), actionId) ||
						permissionChecker.hasPermission(
							category.getGroupId(), MBCategory.class.getName(),
							categoryId, actionId)) {

						return true;
					}

					categoryId = category.getParentCategoryId();
				}
			}
			catch (NoSuchCategoryException nsce) {
				if (!category.isInTrash()) {
					throw nsce;
				}
			}
		}

		return false;
	}

}